<?php
class Product extends AppModel{
	var $name = 'Product';
	var $useTable = 'products';
	var $primaryKey = 'id';
	var $recursive = 1; 
	
	function loadType() {
		$this->bindModel(
			 array(
			 	'belongsTo' => array (
					'Type' => array(
						'className' => 'ProductType',
						'foreignKey' => 'type'
					)
				)
			), 
			false
		);
	}
	
	function loadSupplier() {
		$this->bindModel(
			 array(
			 	'belongsTo' => array (
					'Supplier' => array(
						'className' => 'Supplier',
						'foreignKey' => 'sanxuat'
					)
				)
			), 
			false
		);
	}
	
	function gStandard(){
		$a = $this->find('all',array(
			'group' => 'standard',
			'fields' => 'standard'
		));
		foreach ($a as $i) {
			$res = $i['Product']['standard'];
		}
		return $res;
	}
}
?>
